import React, { useState, useEffect } from 'react'
import {toJS} from 'mobx'
import {observer} from 'mobx-react'
import useStore from '../hooks/useStore'
const Page:React.FC =()=>{
    const {userStore} = useStore()
    const {user,setUserName} = userStore
    const [name,setName] = useState('')
    useEffect(()=>{
        console.log(toJS(user))
        setName(user.name)
    },[user.name])
    const handleClick =()=>{
        setUserName("fuck")
    }
    return<div>{name}<p>{userStore.user.name}</p> <button onClick={handleClick}>设置</button></div>
}
export default observer(Page)